package com.example.sharding.jdbc.demo.mapper;

import com.baomidou.dynamic.datasource.annotation.DS;
import com.example.sharding.jdbc.demo.constants.DSConstants;
import com.example.sharding.jdbc.demo.domain.TestLog;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.Date;
import java.util.List;

/**
 * @author airtrioa
 * @date 2021/11/30
 */
@Mapper
@DS(DSConstants.TEST_LOG_DS_NAME)
public interface TestLogMapper {
  /**
   * 根据 Start End 把范围限制在 几张分片表里面
   *
   * @param start
   * @param end
   * @return
   */
  @Select("SELECT id,name,wait_time AS waitTime FROM test_log WHERE wait_time BETWEEN #{start} AND #{end}")
  List<TestLog> findList(@Param("start") Date start, @Param("end") Date end);
}
